<template>
	<view class="content">
		<image :src="url" mode=""></image>
		<view class="toLive_btn" @click="toLive">
			进入直播
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				id: '',
				url: ''
			}
		},
		onLoad(options) {
			if (options.q) {
				let scene = decodeURIComponent(options.q)
				var url = scene;
				uni.showToast({
					title:url
				})
				var index = url.lastIndexOf("\/");
				// 通过扫码进入时需要将用户和行程绑定，由于课程存在未登录状态，所以设置全局标识，在绑定成功后删除
				this.id = url.substring(index + 1, url.length)
			} else {
				this.id = options.id
			}
			this.getLiveDetail()
		},
		methods: {
			getLiveDetail() {

				let that = this
				that.$http('live.liveInfo', {
					id: this.id
				}, '加载中...').then(res => {
					console.log(res)
					if (res.code == 1) {
						this.url = res.data.cover
					}
				})
			},
			toLive() {
				uni.redirectTo({
					url: '/pages/liveDetail/detail?id=' + this.id
				})
			}
		}
	}
</script>

<style lang="scss" scoped>
	.content {
		width: 100%;
		height: 100%;

		image {
			width: 100%;
			height: 100%;
		}
	}

	.toLive_btn {
		position: absolute;
		bottom: 150rpx;
		left: 0;
		right: 0;
		margin: auto;
		width: 300rpx;
		color: #fff;
		background: linear-gradient(rgba(0, 0, 0, .3), rgba(255, 255, 255, .3));
		border-radius: 50px;
		padding: 20rpx 10rpx;
		text-align: center;
		border: 1px solid #fff;
	}
</style>